
// <copyright file="RandomHelper.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The random helper.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Algorithms
{
    using System;

    using SubhadraSolutions.Sharp.Utils.Reflection;

    /// <summary>
    /// The RandomObject helper.
    /// </summary>
    public static class RandomHelper
    {
        #region Constants

        /// <summary>
        ///     The lower chars
        /// </summary>
        public const string LowerChars = "abcdefghijklmnopqrstuvwxyz";

        /// <summary>
        ///     The lower numeric chars
        /// </summary>
        public const string LowerNumericChars = "abcdefghijklmnopqrstuvwxyz0123456789";

        /// <summary>
        ///     The numeric chars
        /// </summary>
        public const string NumericChars = "0123456789";

        /// <summary>
        ///     The upper chars
        /// </summary>
        public const string UpperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        /// <summary>
        ///     The upper lower chars
        /// </summary>
        public const string UpperLowerChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

        /// <summary>
        ///     The upper lower numeric chars
        /// </summary>
        public const string UpperLowerNumericChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

        /// <summary>
        ///     The upper numeric chars
        /// </summary>
        public const string UpperNumericChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

        #endregion Constants

        #region Static Fields

        /// <summary>
        ///     The RandomObject
        /// </summary>
        private static readonly Random RandomObject = new Random();

        #endregion Static Fields

        #region Public Methods and Operators

        /// <summary>
        /// Builds the RandomObject string.
        /// </summary>
        /// <param name="length">
        /// The length.
        /// </param>
        /// <param name="inputChars">
        /// The input chars.
        /// </param>
        /// <returns>
        /// System.String.
        /// </returns>
        /// <remarks>
        /// [CAUTION]. [CALLED BY REFLECTION]
        /// </remarks>
        [CautionUsedByReflectionAttribute]
        public static string BuildRandomString(int length, string inputChars = UpperLowerNumericChars)
        {
            var chars = new char[length];
            for (int i = 0; i < length; i++)
            {
                chars[i] = inputChars[RandomObject.Next(inputChars.Length)];
            }

            return new string(chars);
        }

        #endregion Public Methods and Operators
    }
}